package com.shanyue.controller;

import com.shanyue.pojo.User;
import com.shanyue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public String login(@RequestParam("username") String username, @RequestParam("password") String password, HttpSession session){
        System.out.println("username:"+username+" password:"+password);
        User user = userService.login(username, password);
        session.setAttribute("user",user);
        System.out.println(user);
        return "redirect:/ZhengRenRenZhengController/queryList";
    }

}
